﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MLY.LTR
{
    public partial class TPTRawDataView1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
                RawDataGridview.HeaderRow.TableSection = TableRowSection.TableHeader;
        }

        protected void RefreshData(object sender, EventArgs e)
        {
            TPTRawDataSource.SelectParameters.Clear();
            if (DatesFromDDL.SelectedIndex > 0)
            {
                TPTRawDataSource.SelectParameters.Add("Date", DatesFromDDL.SelectedValue);
            }

            if (DatesTillDDL.SelectedIndex > 0)
            {
                TPTRawDataSource.SelectParameters.Add("DateTill", DatesTillDDL.SelectedValue);
            }

            if (OldLifeCycleStageDDL.SelectedValue != "1000")
            {
                TPTRawDataSource.SelectParameters.Add("OldLifeCycleStage", OldLifeCycleStageDDL.SelectedValue);
            }

            if (NewLifeCycleStageDDL.SelectedValue != "0")
            {
                TPTRawDataSource.SelectParameters.Add("NewLifeCycleStage", NewLifeCycleStageDDL.SelectedValue);
            }

            if (WorkOrderIdDDL.SelectedValue != "0")
            {
                TPTRawDataSource.SelectParameters.Add("WorkOrderId", WorkOrderIdDDL.SelectedValue);
            }

            RawDataGridview.DataBind();
        }

        protected void ExportToExcel(object Sender, EventArgs e)
        {
            MLY.Bll.ExcelExport.PrepareCsvFileFromGridview(RawDataGridview, "TPTRawData");
        }
    }
}
